f9a22291d46802048dec832887c040d0b67abb02,Mage/src/mage/abilities/effects/common/continious/ExchangeControlTargetEffect.java,ExchangeControlTargetEffect,init,#Ability#Game#,80
Before Change
controllers.add(source.getControllerId());
}
// exchange works only for two different controllers
if (controllers.size() != 2) {
// discard effect
this.discarded = true;
return;
}
this.lockedControllers = new HashMap<UUID, UUID>();
Iterator<UUID> it = controllers.iterator();
UUID firstController = it.next();
UUID secondController = it.next();
if (withSource) {
Permanent targetPermanent = game.getPermanent(targetPointer.getFirst(game, source));
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
if (targetPermanent != null && sourcePermanent != null) {
this.lockedControllers.put(targetPermanent.getId(), sourcePermanent.getControllerId());
this.lockedControllers.put(sourcePermanent.getId(), targetPermanent.getControllerId());
}
After Change
}
@Override
public void init(Ability source, Game game) {
Permanent permanent1 = null;
Permanent permanent2 = null;
if (withSource) {
permanent1 = game.getPermanent(targetPointer.getFirst(game, source));
permanent2 = game.getPermanent(source.getSourceId());
} else {
for (UUID permanentId : targetPointer.getTargets(game, source)) {
if (permanent1 == null) {
permanent1 = game.getPermanent(permanentId);
}
if (permanent2 == null) {
permanent2 = game.getPermanent(permanentId);
}
}
if (withSecondTarget) {
UUID uuid = source.getTargets().get(1).getFirstTarget();
permanent2 = game.getPermanent(uuid);
}
}
if (permanent1 != null && permanent2 != null) {
// exchange works only for two different controllers
if (permanent1.getControllerId().equals(permanent2.getControllerId())) {
// discard effect if controller of both permanents is the same
discard();
return;